package ipaintplugin.actions;

import ipaintplugin.editors.DrawingEditor;
import ipaintplugin.editors.MultiPaintEditor;

import org.eclipse.jface.action.Action;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;

/**
 * Our sample action implements workbench action delegate. The action proxy will
 * be created by the workbench and shown in the UI. When the user tries to use
 * the action, this delegate will be created and execution will be delegated to
 * it.
 * 
 * @see IWorkbenchWindowActionDelegate
 */
public class DrawRedoAction extends Action implements IWorkbenchAction {

	private static final String ID = "ipaintplugin.actions.drawredo";

	public DrawRedoAction() {
		setId(ID);
		setText("Redo");
	}

	public void run() {

		IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getActivePage().getActiveEditor();
		if (part != null) {

			if (part instanceof MultiPaintEditor) {
				DrawingEditor deditor = (DrawingEditor) ((MultiPaintEditor)part).getDrawingEditor();
				deditor.redo();
			}
		}
	}

	public void dispose() {
	}

}